﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Threading;
using System.Web;
using System.Web.Security;

namespace Deixei.Domain
{
    //public class DataContextInitializer : DropCreateDatabaseIfModelChanges<DataContext>
    public class DataContextInitializer : DropCreateDatabaseAlways<DataContext>
    {

        protected override void Seed(DataContext context)
        {


            MembershipCreateStatus Status;
            Membership.CreateUser("Demo", "123456", "demo@demo.com", null, null, true, out Status);
            Roles.CreateRole("Admin");
            Roles.AddUserToRole("Demo", "Admin");
            

            context.BaseEntitiesType.Add(new BaseEntityType
            {
                Id = 1,
                TypeCode = "UserType",
                Name = "Administrator",
                Description = "Administrator"
            });
            
            context.Ingredients.Add(new Ingredient
            {
                Name = "Batatas"
            });

            context.Ingredients.Add(new Ingredient
            {
                Name = "Cenouras"
            });

            context.Ingredients.Add(new Ingredient
            {
                Name = "Vinho tinto"
            });

            context.Ingredients.Add(new Ingredient
            {
                Name = "Vinho branco"
            });


            context.SaveChanges();
            base.Seed(context);
        }

    }
}
